/**
 * Copyright (C) 2012 The SkyTvOS Project
 * <p/>
 * Version     Date           Author
 * ─────────────────────────────────────
 * 2014年8月29日         Root.Lu
 */

package com.coocaa.x.service.litedaemon.daemons.tvpie.app.bean;

import com.coocaa.x.framework.data.JObject;
import com.coocaa.x.service.litedownloader.data.DownloadTask;
import com.coocaa.x.service.litedownloader.data.ProcessInfo;

import java.util.UUID;

public class AppMessage extends JObject {
    public String id = UUID.randomUUID().toString();

    public String msg = EMPTY_STRING;
    public String extra = EMPTY_STRING;

    public String params = EMPTY_STRING;
    public String result = EMPTY_STRING;


    public static void main(String[] args) {
        AppMessage msg = new AppMessage();
        msg.msg = "aaaaamsg";
        msg.extra = "aaaaaextra";
        System.out.println(msg);
    }

    public AppMessage() {

    }

    public static class MobileAppInfo extends JObject {
        public static final int FLAG_MASK_CHILD_LOCK = 1 << 0;
        public String appName = EMPTY_STRING;
        public String pkgName = EMPTY_STRING;
        public String mainActivity = EMPTY_STRING;
        public int flag = 0;
        public String apkPath = "";
    }

    public static class MobileApkInfo extends JObject {
        public String name = EMPTY_STRING;
        public String path = EMPTY_STRING;
        public String extra = EMPTY_STRING;
    }

    public static class MobileDownloadProcessInfo extends JObject {
        public DownloadTask task = null;
        public ProcessInfo process = null;
    }

    public static class MobileDownloadFinishInfo extends JObject {
        public DownloadTask task = null;
        public MobileApkInfo apkinfo = null;
    }

    public static class MobileTvInfo extends JObject {
        public String channel = EMPTY_STRING;
        public String mac = EMPTY_STRING;
        public boolean isRoot = false;
    }

    public static class MobileAppStatus extends JObject {
        public static final int HAS_INSTALLED_MASK = 1;
        public static final int CAN_UPDATE_MASK = 2;
        public static final int DOWNLOAD_READY_MASK = 4;
        public static final int DOWNLOAD_PROCESS_MASK = 8;
        public static final int DOWNLOAD_STOP_MASK = 16;
        public static final int DOWNLOAD_FINISH_MASK = 32;

        public MobileAppInfo appinfo = new MobileAppInfo();
        public int status;
        public int progrss;

        public MobileAppStatus() {

        }

        public boolean isInstalled() {
            return checkStatus(HAS_INSTALLED_MASK);
        }

        public boolean canUpdate() {
            return checkStatus(CAN_UPDATE_MASK);
        }

        public int getDownloadStatus() {
            int ready = status & DOWNLOAD_READY_MASK;
            int process = status & DOWNLOAD_PROCESS_MASK;
            int stop = status & DOWNLOAD_STOP_MASK;
            int finish = status & DOWNLOAD_FINISH_MASK;
            return ready | process | stop | finish;
        }

        public boolean checkStatus(int mask) {
            return ((status & mask) > 0);
        }
    }

    public static class PackageInstallerInfo extends JObject {
        public static final int TYPE_INSTALL_START = 0;
        public static final int TYPE_INSTALL_END = 1;
        public static final int TYPE_UNINSTALL_START = 2;
        public static final int TYPE_UNINSTALL_END = 3;

        public int type = -1;
        public boolean success = false;

        public String name = EMPTY_STRING;
        public String pkgname = EMPTY_STRING;
        public String extra = EMPTY_STRING;
    }

    public static class ApkInfoBean extends JObject {
        public String appid;
        public String extra;
    }


}
